<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>内容管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="/favicon.ico">
    <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <!-- Data Tables -->
    <link href="/static/admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

    <!-- Sweet Alert -->
    <link href="/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="/static/admin/css/animate.css" rel="stylesheet">
    <link href="/static/admin/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>分类列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="">
                        <a href="{:url('Category/add')}" class="btn btn-primary">添加分类</a>
                    </div>
                    <table class="table table-striped table-responsive table-bordered table-hover" id="editable">
                        <thead>
                        <tr>
                            <th><input type="checkbox" name="id"></th>
                            <th>ID</th>
                            <th>分类名称</th>
                            <th>排序</th>
                            <th>状态</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach $list as $v}
                        <tr>
                            <td><input type="checkbox" name="id[]" value="{$v.id}"></td>
                            <td>{$v.id}</td>
                            <td>{:html_entity_decode($v.title)}</td>
                            <td>{$v.order}</td>
                            <td>{:html_entity_decode($v.status)}</td>
                            <td>{$v.create_time}</td>
                            <td>
                                <a href="{:url('Category/add', array('pid' => $v.id))}"
                                   class="btn btn-success" title="添加子分类"><i class="fa fa-plus"></i></a>
                                <a href="{:url('Category/edit', array('id' => $v.id))}" class="btn btn-primary"><i
                                        class="fa fa-edit" title="编辑"></i></a>
                                <a href="javascript:;" data-id="{$v.id}" onclick="confirm_msg(this)"
                                   class="btn btn-danger" title="删除"><i class="fa fa-trash"></i></a>
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>


<script src="/static/admin/js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="/static/admin/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="/static/admin/js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!-- 自定义js -->
<script src="/static/admin/js/content.js?v=1.0.0"></script>

<!-- Sweet alert -->
<script src="/static/admin/js/plugins/sweetalert/sweetalert.min.js"></script>


<!-- Page-Level Scripts -->
<script>
    $(document).ready(function () {
        $('#editable').dataTable();
    });

    function confirm_msg(obj) {
        var id = $(obj).attr('data-id');
        var url = "/admin/Category/delete";
        swal({
            title: "您确定要删除这条信息吗",
            text: "删除后将无法恢复，请谨慎操作！",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "删除",
            closeOnConfirm: false
        }, function (isConfirm) {
            if (isConfirm) {
                $.post(url, {id: id}, function (data) {
                    if (data.code === 1) {
                        swal("删除成功！", data.msg, "success");
                        setTimeout(function () {
                            location.href = '/admin/Category/index';
                        }, 2000);
                    } else {
                        swal("删除失败！", data.msg, "error");
                    }
                }, 'json');
            } else {
                swal("已取消", "您取消了删除操作！", "error");
            }
        });
    }
</script>

</body>

</html>
